@extends('admin.layouts.app')
@section('headerCss')
    @parent
    <style>
        .w88 {
            width: 88px!important;
        }
    </style>
@stop
@section('content')
    <div id="add_ads_style">
        {{ Form::model($kil,['route' => ['kil.update',$kil->id],'method' => 'PATCH' ,'id' =>'form']) }}
        <div class="add_adverts">
            <ul>
                <li><label class="label_name w88">起始区间</label><span class="cont_style">
                        <input name="min_kil"  type="text" value="{{ $kil->min_kil }}"
                               id="min_kil" placeholder="" class="col-xs-10 col-sm-5" style="width:150px"></span>
                </li>
                <li><label class="label_name w88">结束区间</label><span class="cont_style">
                        <input name="max_kil"  type="text" value="{{ $kil->max_kil }}"
                               id="max_kil" placeholder="" class="col-xs-10 col-sm-5" style="width:150px"></span>
                </li>
                <li><label  class="label_name w88">金额</label><span class="cont_style">
                        <input name="price" type="text" value="{{ $kil->price }}"
                               id="form-field-1" placeholder="" class="col-xs-10 col-sm-5" style="width:90px"></span>
                </li>
                <li>
                    <div class="Button_operation">
                        <button type class="btn btn-primary radius" type="submit">保存并提交</button type>
                        <button onclick="layer_close()" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
                    </div>
                </li>
            </ul>
        </div>
        {!! Form::close() !!}
    </div>

@stop
@section('js')

<script type="text/javascript">
    $('#form').Validform({
        tiptype : 4,
        ajaxPost : true,
        beforeCheck:function(curform){
            console.log(curform);
            //在表单提交执行验证之前执行的函数，curform参数是当前表单对象。
            //这里明确return false的话将不会继续执行验证操作;
            index = layer.load(1, {shade: [0.6, '#393D49']});
        },
        callback : function (res) {
            console.log(res);
            if(res.status == 422) {
                var json=JSON.parse(res.responseText);
                $.each(json.errors, function(idx, obj) {
                    layer.msg(obj[0], {icon: 5});
                    layer.close(index);
                    return false;
                });
            } else if(res.status== 200) {
                layer.msg(res.msg, {
                    icon: 1,
                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                }, function(){
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    parent.location.href = '{{ route('kil.index') }}'
                });

            }
        },
    });
</script>
@stop
